package com.example.demo.service;


import com.example.demo.model.GymMembership;
import com.example.demo.repository.GymMembershipRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public class GymMembershipService {
    @Autowired
    private GymMembershipRepository gymMembershipRepository;

    public List<GymMembership> getAll(GymMembership gymMembership){
        return gymMembershipRepository.findAll(Example.of(gymMembership));
    }
    public GymMembership get(Long id) {
        return gymMembershipRepository.getReferenceById(id);
    }
    public void delete(Long id) {
        gymMembershipRepository.deleteById(id);
    }

    public  void save(GymMembership gymMembership) {
        gymMembershipRepository.save(gymMembership);
    }
}
